{% include 'front/header1.html' %}
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.6&key=4cf311835bbf55ce280047af1fbd7c85&plugin=AMap.CitySearch"></script>

<style type="text/css">
	body {
		height: 100%;
	}
	
	.mui-bar {
		background: #000000 !important;
		color: #fff !important;
		position: relative !important;
	}
	
	.mui-title {
		color: #fff !important;
	}
	
	#top-content img {
		width: 100%;
	}
	
	.mui-bar {
		position: absolute;
	}
	
	.mui-bar .mui-title {
		left: 0;
		right: 0;
	}
	
	.left {
		text-align: left !important;
	}
	
	.right {
		text-align: center !important;
	}
	
	textarea,
	p {
		margin-bottom: 0;
	}
	
	#bottom-content {
		/*padding: 0 19px;*/
		display: flex;
	}
	
	.content {
		position: absolute;
	}
	
	#ly p {
		color: .12rem;
		color: #333;
	}
	
	.other {
		/*padding: 0 19px;*/
		width: 100%;
		display: flex;
		flex-flow: row;
		flex-wrap: wrap;
		justify-content: space-between;
	}
	
	.content {
		padding-top: 0px !important;
		width: 100%;
	}
	
	input {
		font-size: .12rem;
	}
	
	#submit {
		color: #fff;
	}
	
	.get-money {
		width: 2.9rem;
		height: 3.04rem;
		position: fixed;
		top: 1.23rem;
		z-index: 1001;
		margin: auto;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
	}
	
	.get-money1 {
		width: 7.733333rem;
		top: 246px;
		z-index: 1001;
		margin: auto;
		position: relative;
	}
	
	.alert-img-box {
		width: 100%;
		height: 100%;
		position: relative;
	}
	
	.alert-img-box img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	
	.alert-img-box .p {
		display: flex;
		flex-flow: column;
		justify-content: center;
		position: absolute;
		left: 0;
		right: 0;
		bottom: .44rem;
	}
	
	.alert-img-box .p p {
		text-align: center;
		color: #fff;
		margin-bottom: .14rem;
		font-size: .17rem;
	}
	
	.top-tool {
		width: 100%;
		height: .66rem;
		background: #fff;
	}
	
	.top-tool .ye,
	.top-tool .lb {
		width: 100%;
		height: .66rem;
		display: flex;
		flex-flow: row;
		padding: 0 .25rem 0 .18rem;
		align-items: center;
		justify-content: space-between;
		z-index: 2000;
	}
	
	.ye .my-pay-btn {
		width: .6rem;
		height: .25rem;
		color: #fff;
		background: #00d4d2;
		border-radius: .03rem;
		text-align: center;
		line-height: .25rem;
		font-size: .12rem;
	}
	
	.ye span,
	.lb span {
		font-size: .15rem;
	}
	
	.lb .get-money-btn {
		width: .6rem;
		height: .25rem;
		color: #fff;
		background: #fe0154;
		border-radius: .03rem;
		text-align: center;
		line-height: .25rem;
		font-size: .12rem;
	}
	
	.alert-con {
		width: 100%;
		position: absolute;
		top: 1.8rem;
		bottom: 0;
		left: 0;
		right: 0;
		margin: auto;
		z-index: 1040;
	}
	
	.alert-con h3 {
		text-align: center;
	}
	
	#ruleList p {
		color: #333;
		margin-bottom: 0.053333rem;
		/*font-size: 0.373333rem*/
	}
	
	.rule-title {
		margin-top: 0.253333rem;
		color: #00d4d2;
		margin-bottom: 0.253333rem;
		font-size: 14px;
	}
	
	.rule-line {
		width: 100%;
		height: 0.013333rem;
		background: #dadada;
		margin-top: 0.493333rem margin-bottom: 0.306666rem
	}
	
	.longtap {
		position: relative;
		/*display: inline-block;*/
	}
	
	.money {
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		z-index: 1000;
		font-size: 0.56rem;
		text-align: center;
		line-height: 0.533333rem;
		background: rgba(218, 62, 46, .7);
	}
	
	#top-content .getmoney,
	#top-content .getmoney1,
	.getmoney2 {
		position: relative;
		display: block !important;
	}
	
	#top-content .getmoney2:before {
		content: "";
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		background: rgba(218, 62, 46, .7);
	}
	/*.getmoney2:before*/ 
	#top-content .getmoney1:before{
		content: "";
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		background: rgba(120, 12, 189, 0.7);
	}
	
	.ql-snow {
		position: relative;
	}
	
	body {
		background: #fff !important;
	}
	
	.ql-editor {
		padding: 0 !important;
	}
	
	#phone{
		position: absolute;
		right: 0;
		cursor: pointer;
		display: none;
	}
	
	#phone img {
		width: 2.5rem;
	}
	
	.close{
		position: absolute;
		top: 0;
		right: 0;
		width: 29px !important;
	    height: 29px !important;
	    top: -12px !important; 
	    right: 4px !important;
	}
	.tel{
		width: ;
		position: fixed;
		top: 2.45rem;
		left: 0;
		right: 0;
		margin: auto;
		width: 5.213333rem;
		height: 130px;
		background: #fff;
		border-radius: 0.066666rem;
		font-size: 0.293333rem;
		display: flex;
		justify-content: center;
		align-items: center;
		color:#00d4d2 ;
		z-index: 1501;
	}
	.close1{
		width: 0.4rem;
		position: absolute;
		top: -0.186666rem;
		right: -0.186666rem;
	}
	.tj_address1{
		color: #da3e2e;
		text-decoration: underline;
	}
</style>
<script>
	function setFont() {
		var HTML = document.getElementsByTagName('html')[0];
		/*var dpr=1;//像素比
		var Size=document.documentElement.clientWidth*dpr/10;*/
		//把viewport视口分成10份的rem,html的font-size为1rem
		var Size = document.documentElement.clientWidth / 10;
		if(Size >= 75) {
			Size = 75
		}
		HTML.style.fontSize = Size + 'px';
		var body = document.getElementsByTagName('body')[0];
		body.style.margin = '0 auto';
		body.style.width = Size * 10 + 'px';
	};
	setFont(); //初始适配
	window.onresize = function() { //窗口大小改变适配
		setFont();
	};
</script>
<div class="" style="max-width: 600px; margin:0 auto ;position: relative;background: #fff !important;">
	<div class="content">

		<div class="" style="padding:15px; background: #f4f4f4; position: relative;">
			
			<div id="" style="    width: 100%;max-width: 600px; background: transparent;margin: auto;position: fixed; top: 0;z-index: 1500;">
				<div id="phone" style="right: 15px;">
					<div class="getmoney2" style="display:block;">
						<div class="money" id="money" style=" font-size: 0.16rem;height: 0.933333rem;background: rgba(120, 12, 189, 0.7); border-radius: 17px 0 0 18px;line-height: .4rem;"></div>
					</div>
					<img src="/resource/front/images/forward/phone_num.jpg" />
				</div>
			</div>
			<div id="" style="display: flex; flex-flow: row;font-size: 0.186666rem;">
				<!--<div class="" style="font-size: 13px; flex: 0 0 35%;">
					
				</div>-->
				
				<div class="" id="ruleList" style="margin-left:0.133333rem;font-size:0.133333rem">
					<p style=" font-weight: 600; ">龙采币获取规则:</p>
					<p>1、广告传播区域 <span class="tj_address"></span></p>
					<!--<p>2、广告页推广时效：<span class="promote_day"></span>天</p>-->
					<p>2、广告页有效浏览1/2页，有效时长<span class="look_time_yhd"></span>秒<span class="look_money_yhd"></span>LCB</p>
<!--					<p>4、达到以上要求奖励：<span class="cb_money"></span>LCB / 次</p>-->
					<p>3、点击下方广告模块获取相应龙采币<p>
					<p>4、获取更多龙采币秘籍：此页面分享给好友，好友进行阅读点击达到上述标准后，作为宝宝的你就会获得更多龙采币哟，快去分享哟</p>
				</div>
			</div>
			<div class="rule-line">

			</div>
			<!--<div class="rule-title">
				<span id="">
					点击模块奖励
				</span>
				<span id="">
					见广告图
				</span>
			</div>-->
			<div id="top-content">
			</div>
			<div id="" class="" style="padding: .15rem .19rem; ">

				<div id="bottom-content"></div>
				<div class="other" id="form" style="display: none;">
					<input field="name" required="true" errmsg="请输入姓名" style="margin-top: 0.213333rem; width:  45%;  padding-left: 5px;   font-size: 16px; border-color: #999; height: 0.16rem; " placeholder="姓名" type="text" class="mui-input-password" data-input-password="3">
					<input field="tel" required="true" errmsg="请输入电话" style="margin-top: 0.213333rem;  width:  45%; padding-left: 5px;border-color: #999;     font-size: 16px;height: 0.16rem;" type="number" placeholder="电话" class="mui-input-password" data-input-password="3">
					<textarea field="content" required="true" errmsg="请输入备注" style="width: 100%; height: 1.866666rem;font-size: 0.16rem;     font-size: 16px; border-color: #999; " name="" rows="" cols="" placeholder="备注"></textarea>
					<div id="" class="getmoney2" style="margin-top: 19px;width: 100%;border-color: #3f81f7;border-radius: 2px;">
						<input type="button" id="submit" value="提交" style="width: 100%;background-color: #3f81f7;border-color: #3f81f7;border-radius: 2px;">
						<div class="money" style="font-size:0.213333rem; background: rgba(120, 12, 189, 0.7);">点击进入此模块赚<span id="money1"></span>LCB</div>
					</div>
				</div>
			</div>
			<div class="js_dialog" style="opacity: 1; display: none;">
				<div class="weui-mask"></div>
			</div>
			<!--<img id="qrcode" class="longtap" src="/resource/front/images/forward/money.png" />-->
			<div class="get-money" style="opacity: 1; display: none;">
				<div class=" alert-img-box">
					<div id="">
						<img src="/resource/front/images/forward/money.png" />
					</div>
					<div class="p" style="">
						<p>您得到5个LCB奖励</p>
						<p style="margin-bottom: 0rem; font-size: .17rem;">快来领取吧！</p>
					</div>
				</div>
			</div>
			
			<div class="telbox" style="display: none;z-index: 1501;">
				<div class="tel">
					<img class="close1" src="/resource/front/images/forward/delete.png"  style=""/>
					13698006449
				</div>
			</div>
		</div>
	</div>
</div>
{% include 'front/foot.html' %}
<script type="text/javascript" src="/resource/front/css/mobile/jquery.lazyload.min.js"></script>
<script>
	mui.ready(function() {
		mui.init({
			gestureConfig: {
				longtap: true, //默认为false
				release: true
			}
		});
		this.init();
		this.initRule(); //初始化规则
		this.time = 0;
		this.data = "";
		this.addFeedback(); //添加留言
		this.info = ""; //存放广告信息
		this.rule = "";
		document.querySelector('.js_dialog').addEventListener('touchmove', function(event) {
			event.preventDefault();
		}, false);
		ykp.setLocalStorage('avinfo', window.location.search);

	})

	function showCall() {
		var height = window.screen.height;
		$('#phone').css('top', (height / 2) + 'px');
		window.onresize = function() { //窗口大小改变适配
			$('#phone').css('top', (height / 2) + 'px');
		};
		
		$('#phone').click(function() {
			if(mui.os.ios || mui.os.android) {
				
			} else {
				$('.telbox').show();
			}
		})
		$('.close1').click(function(){
			$('.telbox').hide();
		})
	}

	function initRule() {
		
		var that = this;
		var search = window.location.search;
		search = search.replace(/\?/, "").split("=")[1];
		ykp.doAjax({
			url: "/api/banner/ad_rules",
			method: "post",
			data: {
				ad_id: search.split(",")[0]
			},
			loading: false,
			success: function(res) {
				var data = res.data;
				that.rule = res.data;
				$('#ruleList').find('span').each(function() {
					for(var i in data) {
						if(i == $(this).attr('class')) {
							$(this).text(data[i]);
						}
					}
				})
				$('.look_money_yhd').text(res.data.look_money)
				$('.look_time_yhd').text(res.data.look_time)
				$('.tj_address').attr('type', res.data.promote_type)
				if(res.data.promote_type == 1){
					$('.tj_address').addClass('tj_address1')
				}
				$('.tj_address').click(function() {
					console.log($('.tj_address').attr('type'))
					if($('.tj_address').attr('type') == 1) {
						window.location.href = 'map?lng=' + that.rule.lat + "&lat=" + that.rule.lng + "&km=" + that.rule.km;
					}

				})

			}
		})
	}

	function addFeedback() {
		$('#submit').click(function() {
			var search = window.location.search
			search = search.replace(/\?/, "").split("=")[1];

			var data = ykp.getFormCode({
				el: "#form"
			});
			if(!data) {
				return false;
			}
			ykp.doAjax({
				url: "/api/banner/message_add",
				method: "post",
				data: {
					id: search.split(",")[0],
					name: data.name,
					content: data.content,
					tel: data.tel,
				},
				success: function(res) {
					mui.toast("添加成功");
				}
			})

		})

	}

	function init() {
		var that = this;
		var search = window.location.search
		search = search.replace(/\?/, "").split("=")[1];
		ykp.doAjax({
			url: "/api/banner/banner_detail",
			method: "post",
			data: {
				id: search.split(",")[0],
			},
			success: function(res) {
				var content = JSON.parse(res.data.content);
				this.info = res.data;
				that.getContent(content)
				$('#yylb').text(res.data.earn + "LCB");
				if(res.data.phoneAlert) {
					that.getAlert(JSON.parse(res.data.phoneAlert));
				}
				if(res.data.phone_number) {
					that.getCall(JSON.parse(res.data.phone_number));
				}
//				that.getCall(1)
			}
		})
	}
	
	function getCall(content) {
		console.log(content)
		var that = this;
		// 允许展示 并且有钱的情况下 展示点击模块   手机端打电话  pc端 弹框
		if(content.istel) {
			$("#phone").show().attr('money', content.money).addClass('longtap').addClass('getmoney');
			if(content.money > 0){
				$('#phone .money').text("拨通电话获得"+(content.money || 0)+"LCB")
			}else{
				$('#money').remove()
			}
			if(mui.os.ios || mui.os.android){
				$("#phone a").attr('href','tel:'+content.tel);
			}else{
				$("#phone a").attr('tel',content.tel);
			}
			setTimeout(function(){
				showCall();
			},200)
		}
	}

	function getAlert(content) {
		var html = "";
		//<h3>${content.alert_name}</h3>
		if(content.hasPhoneAlert) {
			html += `
			<div class="alert-con" style="opacity: 1; ">
					<div class="alert-img-box">
						<img class="close" src="/resource/front/images/forward/delete.png" />
						<div id="" class="get-money1 " style="top: 0;width: 95%;">
							<div class="getmoney1" style="display:${content.alert_money ? 'block' :'none'}">
								<div class="money">点击进入此模块赚${content.alert_money}LCB</div>
							</div>
							<a ${content.alert_url_type == 0 ? '' : (content.alert_url_type == 2 ? "href=advInfo?data="+content.alert_next_id : "href="+content.alert_next_id+"")}>
								<img class="lazy" data-original="${content.alert_objUrl_base}" />
							</a>
							
						</div>
						
					</div>
			</div>`;
			$('.js_dialog').show();
			$('.content').append(html);
			$("img.lazy").lazyload({effect: "fadeIn"});
			document.body.style.overflow = 'hidden';
			setTimeout(function() {
				$('.alert-con').remove();
				$('.js_dialog').hide();
				document.body.style.overflow = 'auto';
			}, content.alert_time * 1000)
			$('.close').click(function(){
				$('.alert-con').remove();
				$('.js_dialog').hide();
				document.body.style.overflow = 'auto';
			})
		}
	}

	function getContent(content) {
		console.log(content)
		var html = "";
		var ly = "";
		var data = [{}];
		var search = window.location.search;
		search = search.replace(/\?/, "").split("=")[1];
		var money = "";
		for(var i in content) {
			if(content[i].type == 0) { //单图
				html += "<a class='longtap getmoney'>";
				html += "<img class='lazy' src='" + content[i].img_base + "'><div class='money' style='opacity:" + (content[i].money != 0 ? '1' : '0') + "'>点击进入此模块赚" + content[i].money + "LCB</div></a>";
				html += `<a class='longtap getmoney'  ${(content[i].url_type != 0 ? "href='" + (content[i].url_type == 1 ? content[i].href : 'advInfo?data=' + search.split(",")[0] + ',' + content[i].href) : '')}>`
//				
			} else if(content[i].type == 1) { //标题
				html += `<div  class=" ${content[i].style == 0 ? 'left' : 'right'}" >${content[i].title}</div>`;
			} else if(content[i].type == 2) { //富文本
				html += "<div class='ql-snow  "+ (content[i].money != 0 ? 'getmoney1' : '') +"' style='font-size: 12px;'><div class='money' style='background: rgba(120, 12, 189, 0.7);opacity:" + (content[i].money != 0 ? '1' : '0') + "'>点击进入此模块赚" + content[i].money + "LCB</div>"
				html += "<div  money=" + content[i].money + " style='white-space: pre-wrap' class='longtap richText ql-editor' id='texttrea" + i + "' data-key='" + content[i].key + "'  data-type='" + content[i].type + "'>" + content[i].richText + "</div></div>";
			} else if(content[i].type == 3) { //辅助空白
				var div = "<div  style='" + getStyle(content[i].spaceColor) + "'></div>";
				html += div;
			} 
//			} 
			else if(content[i].type == 6) { //留信息
				ly += `<div id="ly" class='longtap' data-type="${content[i].type}" data-key="${content[i].key}">
				<p style="margin-top: .07rem;word-break: break-all; ${getStyle(content[i].fontSize1)}" >${content[i].title}</p>
				<p style="margin-top:.11rem; ${getStyle(content[i].fontSize2)}">${content[i].info}</p>
			</div>`;
				if(content[i].money) {
					money = content[i].money;
					$('#money1').text(money);
				} else {
					$('#money1').parent().remove();
				}

			} else if(content[i].type == 7) {
				html += '<div class="getmoney lazy" ><div style="opacity:' + (content[i].money ? '1' : '0') + '" class="money">点击进入此模块赚' + content[i].money + 'LCB</div><img class="" id="qrcode" data-key="' + content[i].key + '" data-type="' + content[i].type + '" style="width:100%;" data-original="' + content[i].img_base + '" /></div>'
			}
		}
		$("#top-content").html(html);
		$("#bottom-content").html(ly);
		$("#top-content img").lazyload({
			effect: "fadeIn",
			failurelimit : 10,
			threshold: 200, // 提前开始加载  
		});
		if(ly) {
			$('#form').show();
		}
	}

	function getStyle(obj) {
		var style = "";
		for(var i in obj) {
			style += (i + ":" + obj[i] + ";");
		}
		return style;
	}
</script>